from flask import Flask,render_template,request
from database import get_book_list,get_book_list_by_name
app = Flask(__name__)


@app.route('/')
def hello_world():  # put application's code here
    return 'Hello World!'

@app.route('/index')
def index():
    return app.send_static_file('index.html')
    
@app.route('/render_test')
def render_test():
    book_list=get_book_list()
    
    # s='<table>'
    # s+='<tr><td>bookId</td><td>bookName</td><td>page</td></tr>'
    # for book in book_list:
    #     s+='<tr>'
    #     s+=f'<td>{book[0]}</td>'
    #     s += f'<td>{book[1]}</td>'
    #     s += f'<td>{book[2]}</td>'
    #     s+='</tr>'
    # s+='</table>'
    # # fstring
    # value='23456'
    return render_template('test.html',book_list=book_list)


@app.route('/search')
def search():
    return render_template('search.html')
    pass
    
@app.route('/result')
def result():
    # get 请求
    data=request.args
    # data=request.form post请求book
    query=data['query']
    book_list=get_book_list_by_name(query)
    return render_template('result.html',book_list=book_list)

    
    
    
#



#

if __name__ == '__main__':
    app.run()
